package com.xiaoming.mojbackendquestionservice.controller.inner;

import com.xiaoming.mojbackendquestionservice.service.QuestionService;
import com.xiaoming.mojbackendquestionservice.service.QuestionSubmitService;
import com.xiaoming.mojbackendmodel.model.entity.Question;
import com.xiaoming.mojbackendmodel.model.entity.QuestionSubmit;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/inner")
public class QuestionInnerController {
    @Resource
    private QuestionService questionService;
    @Resource
    private QuestionSubmitService questionSubmitService;
    @GetMapping("/get/questionId")
    public Question getQuestionById(@RequestParam("questionId") Long questionId)
    {
        Question question = questionService.getById(questionId);
        return question;

    }

    @PostMapping("/update/id")
    public boolean updateById( @RequestBody QuestionSubmit questionSubmit)
    {
        boolean update = questionSubmitService.updateById(questionSubmit);
        return update;

    }
    @PostMapping("/update/question/id")
    public boolean updateQuestionById(@RequestBody Question question)
    {
        boolean update = questionService.updateById(question);
        return update;

    }


    @GetMapping("/get/questionSubmitId")
    public QuestionSubmit getQuestionSubmitById(@RequestParam("questionSubmitId") Long questionSubmitId)
    {
        QuestionSubmit questionSubmit = questionSubmitService.getById(questionSubmitId);
        return questionSubmit;
    }



}
